<?php

namespace app\common\service;


class ServerDownload extends Base
{

    /**
     * @name 列表
     * @param $module
     * @param $limit
     * @return array
     * @author wx
     * @date 2019/11/4 14:15
     */
    function list($module, $limit)
    {
        $db = db('server_download');
        $list = $db->field('id, ctime, path, ratio, status')->order('id desc')
            ->where('module', $module)->where('status','<>',3)
            ->paginate($limit)->toArray();

        return $list;
    }



    /**
     * @name 查询
     * @param $condition
     * @return array|null|\PDOStatement|string|\think\Model
     * @author wx
     * @date 2019/11/4 14:16
     */
    function findData($condition, $field = '*')
    {
        return db('server_download')->field($field)->where($condition)->where('status','<>',3)->find();
    }

    /**
     * @name 修改状态
     * @param $module
     * @param $id
     * @return int|string
     * @author wx
     * @date 2019/11/4 14:58
     */
    function del($module, $id)
    {
        return db('server_download')->where('module',$module)->where('id','in',$id)->update(['status' => 3]);
    }

    function add($addData)
    {
        return db('server_download')->insertGetId($addData);
    }

    function modify($condition, $updateData)
    {
        return db('server_download')->where($condition)->update($updateData);
    }
}